package com.haier.tv.mic.detect;

import com.haier.tv.mic.detect.util.LogUtil;
import com.haier.tv.mic.detect.util.Utils;

import java.io.File;

public class HrTvApi {

    public static final String TAG = "HrTvApi";
    private static HrTvApi sHrTvApi = null;

    public static synchronized HrTvApi getInstance(){
        if (null == sHrTvApi)
            sHrTvApi = new HrTvApi();
        return sHrTvApi;
    }


    public int tvMicInit(int channelNum,int sampleRate){
        return 0;
    }

    public int tvMicDeinit(){
        return 0;
    }

    public void beforeMicDetectInit() {

        String recordFilePath = "/storage/emulated/0/recorder";
        File dirFile = new File(recordFilePath);
        if (dirFile.exists() && dirFile.isDirectory()){
            File[] files = dirFile.listFiles();
            if (files != null) {
                for (File file : files) {
                    if (!file.delete()){
                        LogUtil.d(TAG,"delete error");
                    }
                }
            }
        }
    }

    public void beforeMicRecordInit(){
        Utils.setProperty("haier.tv.save.mic.file","true");
    }
}
